<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="forward">前进</button>
    <button id="back">后退</button>
</body>
<script>
    /**
     * window.history
     * 可以省略前面的window
     * 页面的前进到下一个和后退到上一个
    */
    var back = document.getElementById("back");
    back.onclick = function(){
        history.back();//window.history.back();
    }
    var forward = document.getElementById("forward");
    forward.onclick = function(){
        history.forward();
    }
    /**
     * 页面访问历史 go（负值）页面后退
     * go（正值）页面前进
     * go（0）页面刷新
    */
    go.onclick = function(){
        history.go(0);
    }
</script>
</html>